#include <bits/stdc++.h>
using namespace std;
int t;
int n;
const int N=100010;
int a[N];
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>t;
    for(int b=1;b<=t;b++)
    {
        int ans=0;
        cin>>n;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
        }
        for(int i=1;i<=n;i++)
        {
            int cnt=0;
            for(int j=1;j<=n;j++)
            {
                if(i!=j and a[i]==a[j])
                {
                    cnt+=1;
                }
            }
            ans+=cnt*a[i];
        }
        cout<<ans/2<<"\n";
    }
    return 0;
}
